package com.hpin.mlxteacher.message;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.adapter.ClassifyComAdapter;
import com.hpin.mlxteacher.base.BaseActivity;
import com.hpin.mlxteacher.utils.Constant;

import java.util.ArrayList;
import java.util.List;

//import com.umeng.analytics.MobclickAgent;

/**
 * Created by Aaron on 2015/7/21.
 */
public class ClassifyActivity extends BaseActivity {

    /**
     * 分类code
     */
    private static final int CLASSIFY_CODE = 1007;
//    private PullToRefreshListView plv_classify;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_classify);

        initWidget();

    }

    private void initWidget() {

        ImageView tv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);
        TextView tv_right = (TextView) findViewById(R.id.tv_right);

        tv_title.setText(getResources().getString(R.string.classify_title));
        tv_right.setVisibility(View.INVISIBLE);

        tv_left.setOnClickListener(this);

        ListView lv_classify = (ListView) findViewById(R.id.lv_classify);

        List<String> str = new ArrayList<String>();
        str.add(getResources().getString(R.string.rl_news));
//        str.add(getResources().getString(R.string.message_todo));
        str.add(getResources().getString(R.string.message_notice));
        ClassifyComAdapter classifyAdapter = new ClassifyComAdapter(ClassifyActivity.this, str);

        lv_classify.setAdapter(classifyAdapter);

        lv_classify.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Intent data = new Intent();

                switch (position) {
                    case 0:
                        data.putExtra("classifyCode", Constant.MSG_MESSAGE);
                        break;
//                    case 1:
//
//
//                        //代办事件
//                        chooseTodo();
////                        data.putExtra("classifyCode", Constant.MSG_UNFINISHED_WORK);
//                        break;
                    case 1:
                        data.putExtra("classifyCode", Constant.MSG_NOTIFICATION);
                        break;

                }

                setResult(CLASSIFY_CODE, data);
                finish();
            }
        });

//        plv_classify = (PullToRefreshListView) findViewById(R.id.plv_classify);
//
//        plv_classify.setMode(PullToRefreshBase.Mode.BOTH);
//
//        plv_classify.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
//            @Override
//            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
//
////                ClassifyAdapter classifyAdapter = new ClassifyAdapter(ClassifyActivity.this);
//
////                ListView refreshableView = plv_classify.getRefreshableView();
////                refreshableView.setAdapter(classifyAdapter);
//
////                plv_classify.setAdapter(classifyAdapter);
//
//                LogUtil.e("TAG" , "Thread==>" + Thread.currentThread());
//
//                plv_classify.onRefreshComplete();
//
////                classifyAdapter.notifyDataSetChanged();
//
//            }
//
//            @Override
//            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
//                plv_classify.onRefreshComplete();
//            }
//        });

    }

//    /**
//     * 选择代办事件
//     */
//    private void chooseTodo() {
//
//    }

    @Override
    public void widgetClick(View v) {
        switch (v.getId()) {

            case R.id.iv_left:
                //返回
                finish();
                break;

        }
    }

//    public void onResume() {
//        super.onResume();
//        MobclickAgent.onResume(this);       //统计时长
//    }
//
//    public void onPause() {
//        super.onPause();
//        MobclickAgent.onPause(this);
//    }

}
